package com.example.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sun.print.PrinterJobWrapper;


@WebServlet("/loginchk2")
public class LoginCheckServlet2 implements Servlet{

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		System.out.println("Servlet被销毁");
	}

	@Override
	public ServletConfig getServletConfig() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getServletInfo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void init(ServletConfig config) throws ServletException 
	{
		System.out.println("Sevlet 被创建");
	}

	@Override
	public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
		
		System.out.println("Servlet service()被执行");
		
		HttpServletRequest request = (HttpServletRequest)req;
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		
		PrintWriter pw = ((HttpServletResponse)res).getWriter();
		
		pw.print(username+"login ok");
		
	}

}